package com.example.javabasic.thread.classone.demo4;

/**
 * 死锁
 */
public class DeadLock {

    private OtherService otherService ;
    private final Object lock = new Object();

    public void setOtherService(OtherService otherService) {
        this.otherService = otherService;
    }

    public void m1(){
        synchronized (lock){
            System.out.println("method1->m1");
            otherService.s1();
        }
    }

    public void m2(){
        synchronized (lock){
            System.out.println("method1->m2");
            otherService.s1();
        }
    }


    public static void main(String[] args) {

    }
}
